/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Dec 31, 2009
 * Time: 10:32:52 AM
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import org.jdom.Element;

// Referenced classes of package dk.brics.dsd:
//            Rule, Boolexp, Validator, Context,
//            Schema

class RequireRule extends Rule
{

    RequireRule(Element element, Schema schema)
    {
        contents = Boolexp.parseList(element, schema);
    }

    void checkRequirements(Context context, Set set)
    {
        Validator.debug("rule #" + number);
        Iterator iterator = contents.iterator();
        do
        {
            if(!iterator.hasNext())
                break;
            Boolexp boolexp = (Boolexp)iterator.next();
            byte byte0 = boolexp.evaluate(context);
            if(byte0 == 2)
                context.v.invalid(context, "requirement not satisfied for element " + Validator.getElementName(context.e), boolexp.toXML(context));
            else
            if(byte0 == 3)
                context.v.invalid(context, "requirement not always satisfied for element " + Validator.getElementName(context.e), boolexp.toXML(context));
            else
            if(byte0 == 4)
                context.v.invalid(context, "requirement may not be satisfied for element " + Validator.getElementName(context.e), boolexp.toXML(context));
        } while(true);
    }

    List contents;
}

